package Consumer;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public class MyListener_avg implements MessageListener {
    private int count=0;
    double sum=0.0;
    @Override
    public void onMessage(Message message) {
        try {
            count++;
            sum += Double.valueOf(((TextMessage)message).getText());
            System.out.println("Received a message: "+((TextMessage)message).getText());
            System.out.println("均值为："+sum/count);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
